package com.leyou.trade.config;

import com.leyou.auth.utils.UserContext;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FeignConfig {

    //给feign的远程调用添加请求头（JWT信息）
    @Bean
    public RequestInterceptor requestInterceptor(){
        return new RequestInterceptor() {
            @Override
            public void apply(RequestTemplate requestTemplate) {
                requestTemplate.header("Cookie","LY_TOKEN="+ UserContext.getJwt());
            }
        };
    }
}
